/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Entities;

import java.io.Serializable;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author roycalderon
 */
@Entity
@Table(name = "bookType")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "BookType.findAll", query = "SELECT b FROM BookType b"),
    @NamedQuery(name = "BookType.findByIdbookType", query = "SELECT b FROM BookType b WHERE b.idbookType = :idbookType"),
    @NamedQuery(name = "BookType.findByDescription", query = "SELECT b FROM BookType b WHERE b.description = :description"),
    @NamedQuery(name = "BookType.findByLoanDays", query = "SELECT b FROM BookType b WHERE b.loanDays = :loanDays")})
public class BookType implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "idbookType")
    private Integer idbookType;
    @Size(max = 45)
    @Column(name = "description")
    private String description;
    @Column(name = "loanDays")
    private Integer loanDays;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "bookType", fetch = FetchType.LAZY)
    private List<Book> bookList;

    public BookType() {
    }

    public BookType(Integer idbookType) {
        this.idbookType = idbookType;
    }

    public Integer getIdbookType() {
        return idbookType;
    }

    public void setIdbookType(Integer idbookType) {
        this.idbookType = idbookType;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public Integer getLoanDays() {
        return loanDays;
    }

    public void setLoanDays(Integer loanDays) {
        this.loanDays = loanDays;
    }

    @XmlTransient
    public List<Book> getBookList() {
        return bookList;
    }

    public void setBookList(List<Book> bookList) {
        this.bookList = bookList;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idbookType != null ? idbookType.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof BookType)) {
            return false;
        }
        BookType other = (BookType) object;
        if ((this.idbookType == null && other.idbookType != null) || (this.idbookType != null && !this.idbookType.equals(other.idbookType))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "Entities.BookType[ idbookType=" + idbookType + " ]";
    }
    
}
